<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="vue.js"></script>
</head>
<body>
    <!-- 准备一个容器 -->
    <div id="root">
       <!-- 编写组件标签 -->
       
    </div>

    <script type="text/javascript">
        Vue.config.productionTip = false 

        const  student = Vue.extend({
            template:`
                    <div>
                        学生姓名：{{name}}
                        学生年龄：{{age}}
                    </div>    
                    `,
             data(){
                return {
                    name:'zhangsanfe',
                    age:20
                }
             }       

         })

        //创建school对象
         const  school = Vue.extend({
            name:'school',
            template:`
                    <div>
                        学校名称：{{schoolName}}
                        学校地址：{{address}}
                        <student></student>
                        <button @click="showName()">点我</button>
                    </div>    
                    `,
            data(){
                return {
                schoolName:'尚硅谷',
                address:'北京昌平'
                }             
            },
            components:{
                student
            },
            methods: {
                showName(){
                    alert(this.schoolName)
                }
            }

         })

        

         //定义一个hello组件
            const  hello = Vue.extend({
                template:`<h1>{{msg}}</h1>`,
                data(){
                    return {
                        msg:'欢迎来到尚硅谷!!'
                    }
                }
            });

          //定义app组件
          const  app = Vue.extend({
            template:`
                    <div>
                      <hello></hello> 
                      <school></school>     
                    </div>
                    `,
            components:{
                hello,
                school
            }        

          });  
         new Vue({
            template:`<app></app>`,
            el:'#root',
            //注册组件
            components:{
                app
            }
            
         })
    </script>
</body>
</html>